package cn.csust.net2.manager.server.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.csust.net2.manager.server.dao.StudentDAO;
import cn.csust.net2.manager.shared.exception.BeyondAuthorityException;
import cn.csust.net2.manager.shared.po.User;
import cn.csust.net2.manager.shared.service.ModifyPasswordService;
import cn.csust.net2.manager.shared.util.Constant;
import cn.csust.net2.manager.shared.util.ServiceConstant;

@Service(value = ServiceConstant.SERVICE_NAME_MODIFYPASSWORD)
public class ModifyPasswordImpl extends BaseServiceImpl implements ModifyPasswordService {

	@Resource(name = Constant.DAO_NAME_STUDENT)
	private StudentDAO studentDAO;
	
	public StudentDAO getStudentDAO() {
		return studentDAO;
	}

	public void setStudentDAO(StudentDAO studentDAO) {
		this.studentDAO = studentDAO;
	}

	@Override
	@Transactional
	public void modifyPassword(User user, String newPassword)throws BeyondAuthorityException {
		// TODO Auto-generated method stub
		user.setPassword(newPassword);
		studentDAO.update(user);
	}

}
